package com.leap.controller.exception;

import com.leap.entity.RestBean;
import io.swagger.v3.oas.annotations.Hidden;
import jakarta.validation.ValidationException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@Hidden
@RestControllerAdvice
public class ExceptionController {

    @ExceptionHandler(StringIndexOutOfBoundsException.class)
    public RestBean<Void> stirngIndexOutOfBoundsException(StringIndexOutOfBoundsException exception) {
        log.warn("Resolve [{}: {}]",exception.getClass().getName(),exception.getMessage());
        return RestBean.failure(400,"未知错误！ 请稍后重试");
    }

    @ExceptionHandler(IllegalStateException.class)
    public RestBean<Void> stirngIllegalStateException(IllegalStateException exception) {
        log.warn("Resolve [{}: {}]",exception.getClass().getName(),exception.getMessage());
        return RestBean.failure(400, "操作错误！ 请稍后重试");
    }

}
